@use "sass:meta";

@mixin parameter1($default:pink, $name-passing) {
  default: $default;
  name-passing: $name-passing;
}

// 名称传递参数
.name-passing1 {
  @include parameter1($name-passing: name)
}

.name-passing2 {
  @include parameter1($name-passing: name, $default: skyblue)
}

// 默认值参数（可选参数）
.default-param1 {
  @include parameter1($name-passing: name);
}

.default-param2 {
  @include parameter1(skyblue, $name-passing: name);
}

// 个数不定参数
@mixin parameter2($param, $number-indefinite...) {
  param: $param;
  
  // 通过循环获取列表
  @each $var in $number-indefinite {
    #{$var}: $var;
  }
  @for $i from 0 to length($number-indefinite) {
    #{nth($number-indefinite, $i+1)}: $i;
  }
}

$number-indefinite: "number-indefinite1", "number-indefinite2";
.number-indefinite-param1 {
  @include parameter2(param, $number-indefinite..., "number-indefinite3")
}


@mixin parameter3($param, $number-indefinite...) {
  param: $param;
  
  // 通过内置模块`meta.keywords()`获取列表
  // meta.keywords($number-indefinite) = (string: #FFF, comment: #CCC)
  @each $name, $color in meta.keywords($number-indefinite) {
    #{$name}: $color;
  }
}

.number-indefinite-param2 {
  @include parameter3(param, $string: #FFF, $comment: #CCC)
}